function post(url, data, success, error)  {
  var xhr = new XMLHttpRequest();
  xhr.open('POST', url, true)
  xhr.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');
  xhr.onreadystatechange = function() {
    if(xhr.readyState === XMLHttpRequest.DONE && xhr.status === 200) {
      console.log(xhr.responseText)
      var res = JSON.parse(xhr.responseText)
      if(res.error_code === 0){
        success(res)
      }else{
        error(res)
      }
    }
  }
  xhr.timeout = 10 * 1000;
  xhr.ontimeout = function() {
    console.log('请求超时')
    error({error_code: 1, msg: '请求超时'})
  }
  xhr.onabort = function() {
    console.log('请求中断')
    error({error_code: 1, msg: '请求中断'})
  }
  xhr.onerror = function() {
    console.log('请求错误')
    error({error_code: 1, msg: '请求错误'})
  }
  xhr.onloadend = function() {
    console.log('请求完成')
  }
  xhr.onprogress = function(e) {
    console.log('请求进度', e)
  }
  xhr.send(data)
}
function showErr(id, msg) {
  document.getElementById(id + '-msg').innerText = msg
}